package mya.mes.mdc.queries.status;

import mya.common.jpa.context.ServiceContext;
import mya.mes.mdc.model.status.MdcStatus;

import java.util.List;

public class MdcStatusQuery {

    public static List<MdcStatus> queryByZoneId(ServiceContext context, Long zoneId) throws Exception {

        List<MdcStatus> list = context.em.createNamedQuery("MdcStatus.zoneId", MdcStatus.class)
                .setParameter(1, zoneId)
                //   .setLockMode(LockModeType.PESSIMISTIC_WRITE)
                .getResultList();


        return list;
    }

    public static List<MdcStatus> byStatusTypeId(ServiceContext context, Long alarmTypeId) throws Exception {

        List<MdcStatus> list = context.em.createNamedQuery("MdcStatus.byStatusTypeId", MdcStatus.class)
                .setParameter(1, alarmTypeId)
                //   .setLockMode(LockModeType.PESSIMISTIC_WRITE)
                .getResultList();


        return list;
    }

    public static List<MdcStatus> byMdcTag(ServiceContext context, Long zoneId, String mdcTag) throws Exception {

        List<MdcStatus> list = context.em.createNamedQuery("MdcStatus.byMdcTag", MdcStatus.class)
                .setParameter(1, zoneId)
                .setParameter(2, mdcTag)
                //   .setLockMode(LockModeType.PESSIMISTIC_WRITE)
                .getResultList();


        return list;
    }


}
